package com.hmdp.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.data.redis.core.script.RedisScript;

import java.util.List;

@Configuration
public class RedisLuaScripConfigration {

    @Bean(value = "cacheHotFlag")
    public RedisScript<Boolean> cacheHotFlag() {
        DefaultRedisScript<Boolean> cacheHotFlagScript = new DefaultRedisScript<>();
        cacheHotFlagScript.setResultType(Boolean.class);
        cacheHotFlagScript.setLocation(new ClassPathResource("cacheHotFlag.lua"));
        return cacheHotFlagScript;
    }
    @Bean(value = "likeListData")
    public RedisScript<List> likeListData() {
        DefaultRedisScript<List> likeListData = new DefaultRedisScript<>();
        likeListData.setLocation(new ClassPathResource("likeListData.lua"));
        likeListData.setResultType(List.class);
        return likeListData;
    }

}
